package jim.coly.web.service.impl;

import jim.coly.web.domain.User;
import jim.coly.web.repository.UserRepository;
import jim.coly.web.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("userService")
public class UserServiceImpl implements UserService {
	@Autowired
	private UserRepository userRepository; // 注入UserRepository

	@Override
	//@Transactional
	public void saveUser(User user) {
		userRepository.save(user);
	}

	@Override
	public User findUserById(Integer id) {
		return userRepository.findOne(id);
	}

	@Override
	public void updateUser(User user) {
		userRepository.save(user);
	}

	@Override
	public void deleteUserById(Integer id) {
		userRepository.delete(id);
	}

	@Override
	public Page<User> findAllUsersByPage(Pageable pageable) {
		return userRepository.findAll(pageable);
	}


}
